﻿// -----------------------------------------------------------------------
// <copyright file="Circle.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex3
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Ex3.Logic;

    /// <summary>
    /// Represents a circle of friends
    /// </summary>
    public class Circle : IPrototype<Circle>
    {
        public string Name { get; set; }

        public List<SerializableUserInCircuit> FriendsInCircle { get; set; }

        public Circle()
        {
            FriendsInCircle = new List<SerializableUserInCircuit>();
        }

        public Circle(string i_Name, List<SerializableUserInCircuit> i_Frineds)
        {
            Name = i_Name;
            FriendsInCircle = i_Frineds;
        }

        public bool ContainsFriend(string i_FriendID)
        {
            bool doesFrirendExists = false;

            foreach (SerializableUserInCircuit currentFriend in this.FriendsInCircle)
            {
                if (currentFriend.Id == i_FriendID)
                {
                    doesFrirendExists = true;
                    break;
                }
            }

            return doesFrirendExists;
        }

        public Circle DeepClone()
        {
            Circle newCircle = new Circle();
            newCircle.Name = this.Name;

            foreach (SerializableUserInCircuit currentFriend in this.FriendsInCircle)
            {
                SerializableUserInCircuit newFriend = currentFriend.DeepClone();
                newCircle.FriendsInCircle.Add(newFriend);
            }

            return newCircle;
        }

        public Circle Clone()
        {
            return (Circle)this.MemberwiseClone();
        }
    }
}
